﻿<%@ Page Title="异常文件" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="left-side ibox-content">
            <div id="using_json"></div>
        </div>
        <div class="right-side">
            <div class="ibox-title">
                <h5>文件详细</h5>
            </div>
            <div class="ibox-content">
                <textarea id="code"></textarea>
            </div>
        </div>
    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <link href="../assets/css/plugins/jsTree/style.min.css" rel="stylesheet" />
    <link href="../assets/css/plugins/codemirror/codemirror.css" rel="stylesheet" />
    <script src="../assets/js/plugins/codemirror/codemirror.js"></script>
    <script src="../assets/js/plugins/jsTree/jstree.min.js"></script>
    <script>
        $(function () {
            //加载按钮
            commonUtil.loadBtnList(Y.getUrlParam("ModuleID"), function () {
            });
            //刷新按钮
            $('.btns-container').on('click', '#btn-search', function () {
            });
            var editor = CodeMirror.fromTextArea(document.getElementById("code"),
            {
                //lineNumbers: true,
                matchBrackets: true,
                styleActiveLine: true

            });
            editor.setOption('lineWrapping', true); //设置自动换行

            load();

            function load() {
                Y.API2("Common",
                    "GetSysLogs",
                    {},
                    function (data) {
                        if (data.Success == false) {
                            swal(data.Message, '', 'error');
                        } else {
                            var treeData = [];
                            var parentData = {}
                            parentData.text = "Log日志";
                            //parentData.icon = "none";
                            parentData.data = {
                                logText: "Log日志"
                            };
                            if (!Y.checkNull(data) && data.length > 0) {
                                parentData.state = { opened: true };
                                parentData.children = GetChildNode(data);
                            }
                            treeData.push(parentData);
                            $.jstree.destroy("#using_json");
                            $('#using_json')
                                .jstree({
                                    core: {
                                        data: treeData
                                    }
                                })
                                .bind('select_node.jstree',
                                    function (event, data) {
                                        var name = data.node.text;
                                        loadtext(name);
                                    });
                        }
                    });
            }
            function GetChildNode(data) {
                var tempArr = [];
                data.map(function (item, i) {
                    var temp = {}
                    temp.text = item;
                    temp.icon = "fa fa-file-text-o";
                    temp.data = {
                        logText: item
                    }
                    tempArr.push(temp);
                });
                return tempArr;
            };

            function loadtext(name) {
                if (!Y.checkNull(name)) {
                    if (name == "Log日志") return false;
                    Y.API2("Common",
                        "GetSysLogsText",
                        { name: name },
                        function (data) {
                            if (data.Success == false) {
                                swal(data.Message, '', 'error');
                            } else {
                                editor.setValue(data);
                                editor.setSize('auto', 'auto'); //设置自适应高度
                            }
                        });
                }
            }
        })
    </script>
</asp:Content>

